<!-- 监控前端 -->
<template>
    <p class="kjjmxseetwe">
        {{ jhbjser.name }}
    </p>
    <div class='h100 pd pt10 dfgfdgtrt display-flex' :class="jhhbert ? 'fdgrrt' : ''">
        <div class="kjjjsertw">
            <i class="iconfont dx-caidan_o cf sdfsdttrt" v-if="jhhbert" @click="jhhbert = false"></i>
            <i class="iconfont dx-close cf sdfsdttrt" v-else @click="jhhbert = true"></i>
        </div>

        <div class="jk-left bgff pt20 pr " :class="jnert">
            <n-tree block-line cascade :data="Treedata" checkable expand-on-click label-field="title" key-field="id"
                selectable default-expand-all @update:checked-keys="treechange" class="cfgvdfgtyty" />
            <div class="kjjnjmser vertical-center">
                <p class="kjjnsertwx vertical-center" @click="dsfsttyr">
                    <i class="iconfont dx-left b fz32 aa"></i>
                    <i class="iconfont dx-right  fz26 ab "></i>
                </p>
            </div>

        </div>
        <div class="flex-1 ml20 dsfsttyyter" :class="jnert ? 'ml0' : ''">
            <div>

                <draggable class="gezisertewrr" :class="iser" v-model="videoListdemo">
                    <template #item="{ element }">
                        <div class="jnxeerrtw aa sfdgdgfdty pr" :class="element.cls ? 'act' : ''">
                            <EMBED  volume="-10"  class="jnmxeerrt" name="plugin" :src="element.src"
                                type="application/x-shockwave-flash" ></EMBED>

                                
                            <p class="fdgfdyye"></p>
                            <div class="kjhnsertwe" @click="dsfsdrtr(element)">

                            </div>
                        </div>
                    </template>
                </draggable>



                <!-- <div class="jnxeerrtw aa sfdgdgfdty pr" v-for="item in videoListdemo"  :class="item.cls ? 'act' : ''">
                    <embed class="jnmxeerrt" name="plugin" :src="item.src" type="application/x-shockwave-flash" />
                    <p class="fdgfdyye"></p>
                    <div class="kjhnsertwe" @click="dsfsdrtr(item)">

                    </div>
                </div> -->

                <div class="kkmmseterw">
                    <div v-for="item in phoneVideoSourceList" class="jnxeerrtw ab sfdgdgfdty">
                    <videoplay :url="item.src"></videoplay>
                </div>
                </div>
            </div>

        </div>
        <n-button type="primary" size="medium" @click="dsftywer" class="zeerrtwr">自定义布局</n-button>
        <n-modal v-model:show="showModal" preset="card" class="Stock-diagnosis">
            <template #header>
                <div>自定义布局</div>
            </template>
            <div>
                <div class="kjnnxerttw display-flex">
                    <div class="kjnmdetywe gezisertewrr a1" @click="kjnser('a1')">
                        <div v-for="iije in  1" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a4" @click="kjnser('a4')">
                        <div v-for="iije in  4" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a6" @click="kjnser('a6')">
                        <div v-for="iije in  6" class="sfdgdgfdty"></div>
                    </div>

                    <div class="kjnmdetywe gezisertewrr a8" @click="kjnser('a8')">
                        <div v-for="iije in  8" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a9" @click="kjnser('a9')">
                        <div v-for="iije in  9" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a12" @click="kjnser('a12')">
                        <div v-for="iije in  12" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a16" @click="kjnser('a6')">
                        <div v-for="iije in  16" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a20 " @click="kjnser('a20')">
                        <div v-for="iije in  20" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a25" @click="kjnser('a25')">
                        <div v-for="iije in  25" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a30" @click="kjnser('a30')">
                        <div v-for="iije in  30" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a36" @click="kjnser('a36')">
                        <div v-for="iije in  36" class="sfdgdgfdty"></div>
                    </div>
                    <div class="kjnmdetywe gezisertewrr a64" @click="kjnser('a64')">
                        <div v-for="iije in  64" class="sfdgdgfdty"></div>
                    </div>
                </div>


            </div>
            <template #action>
                <div class="tr">
                    <n-button> 取消 </n-button>
                </div>
            </template>
        </n-modal>
    </div>
</template>
<script lang='ts' setup>
import { ref } from "vue";
import Draggable from 'vuedraggable'
import { callBack, dxpost, qurl, dxget, dxdel, dialog, TreeMenudx } from "../../util/index"
import videoplay from "./videoplay.vue"
const Treedata = ref([])
const ishow = ref(false)
const cz = qurl()
const jhhbert = ref(false)
const defaultCheckedKeys = ref([])
const videoList = ref([])
const videoListdemo = ref([])
const phoneVideoSourceList = ref([])
let datapp = []
let jsbj = false // 是否为编辑的状态
let cssg = '810px'
let cssgb = '800px'
let zisdra = '270px'
let zisdrb = '200px'
let zisdrc = '400px'
const iser = ref(localStorage.claer || 'a4')
const showModal = ref(false)
const jnert = ref()
const dsfsttyr = () => {
    if (jnert.value) {
        jnert.value = ""
    } else {
        jnert.value = "act"
    }
}

const onMoveCallback = (e) => {
    console.log(e);
}

const list = ref([
    { name: "John", id: 0 },
    { name: "Joao", id: 1 },
    { name: "Jean", id: 2 }
])
const initData = async (arrs) => {
    const { data }: any = await dxget('jk/jkchannelmanagement')
    const jnjhe = []
    data.map(a => {
        arrs.map(b => {
            if (a.id == b) {
                jnjhe.push(a)
            }
        })
    })
    console.log(jnjhe);
    datapp = jnjhe
    Treedata.value = TreeMenudx(jnjhe)
    if (!jsbj) {
        ishow.value = true
    }
}


const qxlisy = async () => {
    const { data }: any = await dxget("jk/jkrolemanagement?id=" + localStorage.CharacterNameCode)
    if (data.RoleOfTheMenu) {
        initData(data.RoleOfTheMenu.split(","))
    }
}

qxlisy()
const treechange = (data) => {
    videoList.value = []
    phoneVideoSourceList.value = []
    datapp.map(a => {
        data.map(b => {
            if (a.id == b && a.VideoSource) {
                videoList.value.push({
                    id: a.id,
                    src: a.VideoSource,
                    cls: ""
                })
            }
            if (a.id == b && a.phoneVideoSource) {
                phoneVideoSourceList.value.push({
                    id: a.id,
                    src: a.VideoSource,
                    cls: ""
                })
            }

        })
    })


    videoList.value.map(a => {
        let ise = true
        videoListdemo.value.map(b => {
            if (a.id == b.id) {
                ise = false
            }
        })
        if (ise) {
            videoListdemo.value.push(a)
        }

    })

    const jjhnsea = [],
        jjhnseb = []


    videoList.value.map(a => {
        jjhnsea.push(a.id)
    })
    videoListdemo.value.map(b => {
        jjhnseb.push(b.id)
    })
    const arrsde = filterArr(jjhnsea, jjhnseb)
    for (let i = 0; i < arrsde.length; i++) {
        let idxd = 0
        videoListdemo.value.map((a, b) => {
            if (a.id == 1) {
                idxd = b
            }
        })
        console.log('6666');
        videoListdemo.value.splice(idxd, 1)
    }

}


const filterArr = (arr1, arr2) => {
    const arr = [...arr1, ...arr2];
    const newArr = arr.filter((t) => {
        return !(arr1.includes(t) && arr2.includes(t));
    });
    return newArr;
};
const dsftywer = () => {
    showModal.value = true
}
const kjnser = (data) => {
    iser.value = data
    localStorage.claer = data
    showModal.value = false
}
const dsfsdrtr = (data) => {
    if (data.cls) {
        data.cls = ''
    } else {
        data.cls = "act"
    }
}
const jhbjser = ref()
const dajjewe = async ()=>{
  const {data}:any = await  dxget("jk/jkconfig?id=1")
  if(data.data){
    jhbjser.value=  JSON.parse(data.data)
  }
}
dajjewe()
</script>
<style scoped>
.list-group-item {
    height: 50px;
    border: 1px solid red;
}

.jk-left {
    min-height: 100%;
    width: 200px;
    border-radius: 4px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1000;
}

.jk-left.act {
    width: 0px;
}

.jk-left.act .cfgvdfgtyty {
    display: none;
}

.jk-left.act .kjjnjmser {
    right: -8px;
}

.jk-left.act .kjjnsertwx i.aa {
    display: none;
}

.jk-left.act .kjjnsertwx i.ab {
    display: block
}

.jk-left.act .kjjnsertwx i.ab {
    left: 0px
}

.kjjnsertwx i.ab {
    display: none;
}

.gezisertewrr {
    display: grid;
    grid-template-rows: repeat(1, 1fr);
    grid-column-gap: 1px;
    grid-row-gap: 1px;
    grid-template-columns: repeat(3, 1fr);
}

.kjnnxerttw {
    display: grid;
    grid-template-rows: repeat(1, 1fr);
    grid-column-gap: 10px;
    grid-row-gap: 10px;
    grid-template-columns: repeat(10, 1fr);
}

.kjnmdetywe {
    grid-column-gap: 2px;
    grid-row-gap: 2px;
    height: 60px;
}

.kjnmdetywe.a4 {
    grid-template-rows: repeat(2, 1fr);
}

.kjnmdetywe.a6 {
    grid-template-rows: repeat(3, 1fr);
}

.kjnmdetywe.a8 {
    grid-template-rows: repeat(4, 1fr);
}

.kjnmdetywe.a9 {
    grid-template-rows: repeat(3, 1fr);
}

.kjnmdetywe.a12 {
    grid-template-rows: repeat(3, 1fr);
    grid-column-gap: 2px !important;
    grid-row-gap: 2px !important;
}

.kjnmdetywe.a16 {
    grid-template-rows: repeat(4, 1fr);
    grid-column-gap: 2px !important;
    grid-row-gap: 2px !important;
}

.kjnmdetywe.a20 {
    grid-template-rows: repeat(4, 1fr);
    grid-column-gap: 2px !important;
    grid-row-gap: 2px !important;
}

.kjnmdetywe.a25 {
    grid-template-rows: repeat(5, 1fr);
    grid-column-gap: 2px !important;
    grid-row-gap: 2px !important;
}

.kjnmdetywe.a30 {
    grid-template-rows: repeat(5, 1fr);
    grid-column-gap: 2px !important;
    grid-row-gap: 2px !important;
}

.kjnmdetywe.a36 {
    grid-template-rows: repeat(6, 1fr);
    grid-column-gap: 2px !important;
    grid-row-gap: 2px !important;
}

.kjnmdetywe.a64 {
    grid-template-rows: repeat(8, 1fr);
    grid-column-gap: 2px !important;
    grid-row-gap: 2px !important;
}

.kjnmdetywe div {
    background: #e0e0e0;
    min-height: auto !important;
    height: auto !important;
    border: 0;
}


.gezisertewrr.a1 {
    grid-template-columns: repeat(1, 1fr);
}

.gezisertewrr.a4 {
    grid-template-columns: repeat(2, 1fr);
}

.gezisertewrr.b4 {
    grid-template-columns: repeat(3, 1fr);
}

.gezisertewrr.b6 {
    grid-template-columns: repeat(4, 1fr);
}

.gezisertewrr.a6 {
    min-height: v-bind(cssg);
}

.gezisertewrr.a8 {
    min-height: v-bind(cssgb);
    grid-template-columns: repeat(4, 1fr)
}

.gezisertewrr.a12,
.gezisertewrr.a16,
.gezisertewrr.a20,
.gezisertewrr.a25,
.gezisertewrr.a30,
.gezisertewrr.a36,
.gezisertewrr.a64 {
    grid-column-gap: 0px;
    grid-row-gap: 0px;
    grid-template-columns: repeat(4, 1fr)
}

.gezisertewrr.a20,
.gezisertewrr.a25 {
    grid-template-columns: repeat(5, 1fr)
}

.gezisertewrr.a30,
.gezisertewrr.a36 {
    grid-template-columns: repeat(6, 1fr)
}

.gezisertewrr.a64 {
    grid-template-columns: repeat(8, 1fr)
}

.gezisertewrr.a1 .sfdgdgfdty {
    min-height: 810px;
}

.gezisertewrr.a4 .sfdgdgfdty {
    min-height: v-bind(zisdrc)
}

.gezisertewrr.b4 .sfdgdgfdty {
    min-height: 270px
}

.gezisertewrr.a6 .sfdgdgfdty {
    min-height: v-bind(zisdra)
}

.gezisertewrr.a8 .sfdgdgfdty {
    min-height: v-bind(zisdrb)
}

.gezisertewrr.a9 .sfdgdgfdty {
    min-height: v-bind(zisdra)
}

.gezisertewrr.a12 .sfdgdgfdty {
    min-height: v-bind(zisdra)
}

.gezisertewrr.a16 .sfdgdgfdty {
    min-height: 209px
}

.gezisertewrr.a20 .sfdgdgfdty {
    min-height: 209px
}

.gezisertewrr.a25 .sfdgdgfdty {
    min-height: 168px
}

.gezisertewrr.a30 .sfdgdgfdty {
    height: 168px
}

.gezisertewrr.a36 .sfdgdgfdty {
    min-height: 140px
}

.gezisertewrr.a64 .sfdgdgfdty {
    height: 104px
}

.gezisertewrr.b6 .sfdgdgfdty {
    min-height: 410px
}

.gezisertewrr.b4 .sfdgdgfdty:nth-child(1) {
    grid-row: 1 / span 3;

}

.gezisertewrr.a6 .sfdgdgfdty:nth-child(1) {
    grid-row: 1 / span 2;
    grid-column: 1 / span 2
}

.gezisertewrr.a8 .sfdgdgfdty:nth-child(1) {
    grid-row: 1 / span 3;
    grid-column: 1 / span 3
}

.gezisertewrr.b6 .sfdgdgfdty:nth-child(1) {
    grid-column: 1 / span 2
}

.jnxeerrtw {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
}

.jnxeerrtw {
    position: relative;
}

.jnmxeerrt {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.sdfsdttrt {
    position: fixed;
    left: 10px;
    top: 0;
    z-index: 999;
    font-size: 30px;
}

.jnxeerrtw.ab {
    display: none;
}

.jnxeerrtw.act {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.zeerrtwr {
    position: fixed;
    right: 10px;
    bottom: 20px;
    z-index: 9900;
}

.dsfsttyyter {
    min-height: 840px;
    overflow: auto;
}

.kjhnsertwe {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 100;
}

.fdgfdyye {
    position: absolute;
    left: 0;
    top: 0;
    width: 50%;
    height: 40%;
}

.kjjnjmser {
    position: absolute;
    right: 0;
    top: 0;
    width: 20px;
    height: 100%;
}

.kjjnsertwx {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    background: #fff;
    cursor: pointer;
}

.kjjnsertwx i {
    position: relative;
    left: -2px;
}
</style>
<style>
i.iconfont.dx-caidan_o.fz30.ml10 {
    display: none;
}
.kjjmxseetwe{
    position: fixed;
    left: 20px;
    z-index: 9999;
    top: 10px;
    font-size: 18px;
}
</style>